package com.boboPlanet.user.service.impl;

import com.boboPlanet.comm.entity.po.LoginUserInfoPO;
import com.boboPlanet.comm.enums.LoginUserErrorEnum;
import com.boboPlanet.comm.result.ResponseResult;
import com.boboPlanet.user.service.UserCheckService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2023/2/14
 **/
@Service
@Slf4j
public class UserCheckServiceImpl implements UserCheckService {

    /**
     * 校验login
     * @param field 校验字段
     * @param loginEnum 枚举
     * @return  ResponseResult
     */
    @Override
    public ResponseResult<Object> loginCheck(Object field, LoginUserErrorEnum loginEnum) {

        if (null == field){
            return ResponseResult.error(loginEnum,null);
        }
        if (field instanceof LoginUserInfoPO){
            if (((LoginUserInfoPO) field).getAccountId() == null || ((LoginUserInfoPO) field).getUserId() == null){
                return ResponseResult.error(loginEnum,null);
            }
        }
        return ResponseResult.isSuccess();
    }
}
